package com.un.ebs.sys.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.un.ebs.core.enums.ColumnRefTypeEnum;
import com.un.ebs.core.enums.DataTypeEnum;
import com.un.ebs.core.enums.QueryTypeEnum;
import com.un.ebs.core.metadata.DbField;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * (Column)表实体类
 *
 * @author makejava
 * @since 2021-04-25 17:25:25
 */
@Data
@Component
@TableName("sys_column")
@SuppressWarnings("serial")
public class Column extends Model<Column> {

    @TableId(value = "id", type = IdType.UUID)
    private String id;


    @DbField(name = "table_id", length = 40, precision = 0)
    private String tableId;

    @DbField(name = "column_name", length = 100, precision = 0)
    private String columnName;

    @DbField(name = "column_desc", length = 100, precision = 0)
    private String columnDesc;

    @DbField(name = "column_type", length = -1, precision = 0)
    private DataTypeEnum columnType;

    @DbField(name = "is_nullable", length = -1, precision = 0)
    private Boolean isNullable;

    @DbField(name = "length", length = -1, precision = 0)
    private Integer length;

    @DbField(name = "is_pk", length = -1, precision = 0)
    private Boolean isPk;

    @DbField(name = "ref_type", length = -1, precision = 0)
    private ColumnRefTypeEnum refType;

    @DbField(name = "ref_table_name", length = 100, precision = 0)
    private String refTableName;

    @DbField(name = "ref_column_name", length = 100, precision = 0)
    private String refColumnName;

    @DbField(name = "ref_dict_code", length = 100, precision = 0)
    private String refDictCode;

    @DbField(name = "ref_enum_type", length = 100, precision = 0)
    private String refEnumType;

    @DbField(name = "ref_other_code", length = 100, precision = 0)
    private String refOtherCode;

    @DbField(name = "accuracy", length = -1, precision = 0)
    private Integer accuracy;

    @DbField(name = "sort", length = -1, precision = 0)
    private Integer sort;

    @DbField(name = "query_type", length = -1, precision = 0)
    private QueryTypeEnum queryType;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}